import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: () => import('../views/HomeView.vue')
    }, {
      path: '/detail/:id?',
      component: () => import('../views/DetailView.vue'),
      props: route => ({ id: route.params.id })
    }, {
      path: '/new/:id?',
      component: () => import('../views/CreateBlog.vue'),
      props: route => ({ id: route.params.id })
    }
  ]
})

export default router
